<?php
/**
 * Created by PhpStorm.
 * User: jz
 * Date: 16/7/10
 * Time: 下午9:32
 */
require_once('bookmark_fns.php');

$email = $_POST['regi_email'];
$username = $_POST['username'];
$password = $_POST['password'];
$password2 = $_POST['confirm_pass'];

session_start();

try{
    if (!filled_out($_POST)){
        throw new Exception('您的注册信息提交不完整,请重试');
    }
    if (!is_email($email)){
        throw new Exception('请使用有效的邮箱地址');
    }
    if ($password != $password2){
        throw new Exception('两次输入的密码不一致,请重试');
    }
    if (strlen($password) < 6 || strlen($password) > 16){
        throw new Exception('密码长度应该在6-16个字符长度,请返回重试');
    }    
    register($email, $username, $password);
    $_SESSION['valid_user'] = $username;
    do_html_header('注册成功');
    echo '注册成功.进入会员页面去设置您的书签';
    do_html_url('member.php', '进入会员页面');
    do_html_footer();
}catch (Exception $e){
    do_html_header('注册失败');
    echo $e->getMessage();
    do_html_footer();
    exit;
}
?>




